home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 2 / Apprentice-Release2.iso / Source Code / Mark Pilgrim / Jotto ][ 1.2 / source / Jotto code ƒ / jotto.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-10-30  |  1.7 KB  |  79 lines  |  [TEXT/MMCC]

  1. #include "program globals.h"
  2. #include "jotto.h"
  3. #include "jotto keys.h"
  4. #include "jotto meat.h"
  5. #include "jotto load-save.h"
  6. #include "jotto dictionary.h"
  7. #include "jotto environment.h"
  8. #include "error.h"
  9. #include "graphics.h"
  10. #include "window layer.h"
  11.  
  12. #define NUMWIPES 54
  13.  
  14. char            gComputerWord[6];        /* what it really is */
  15. char            gHumanWord[MAX_TRIES+1][6];    /* n-th word guess */
  16. char            gNumRight[MAX_TRIES];    /* # right in n-th try */
  17. unsigned char    gNumTries;                /* # tries so far */
  18. short            gNumComputerWords[2];    /* # total words in computer (5- or 6-letter) dict */
  19. short            gNumHumanWords[2];        /* # total words in human (5- or 6-letter) dict */
  20. unsigned char    gWhichChar;                /* which char in current word the cursor is at */
  21. unsigned char    gNumLetters;            /* 5 or 6 */
  22. char            gAllowDup;                /* allow duplicate letters */
  23. char            gNonWordsCount;            /* non-words count against you */
  24. char            gAnimation;                /* animation? */
  25.  
  26. void InitTheProgram(void)
  27. {
  28.     gWhichWipe=0;
  29.     SetEndGame(FALSE);
  30.     HandleError(OpenTheFiles(), TRUE);
  31. }
  32.  
  33. void NewGame(void)
  34. {
  35.     enum ErrorTypes    resultCode;
  36.     short            i;
  37.     
  38.     gNumTries=0;
  39.     NewWord();
  40.     for (i=0; i<MAX_TRIES; i++)
  41.         gNumRight[i]=0;
  42.     
  43.     resultCode=GetComputerWord();
  44.     if (resultCode!=allsWell)
  45.         HandleError(resultCode, FALSE);
  46.     else
  47.     {
  48.         SetGameInProgress(TRUE);
  49.         StartGame();
  50.     }
  51. }
  52.  
  53. void StartGame(void)
  54. {
  55.     gWhichWipe=gLastWipe+1;
  56.     if (gWhichWipe>NUMWIPES)
  57.         gWhichWipe=1;
  58.     SetEndGame(FALSE);
  59.     OpenTheIndWindow(kMainWindow);
  60.     ObscureCursor();
  61. }
  62.  
  63. Boolean ShutDownTheProgram(void)
  64. {
  65.     WindowPtr        theWindow;
  66.     
  67.     while ((theWindow=GetFrontDocumentWindow())!=0L)
  68.         if (!CloseTheWindow(theWindow))
  69.             return FALSE;
  70.     
  71.     while ((theWindow=FrontWindow())!=0L)
  72.         if (!CloseTheWindow(theWindow))
  73.             return FALSE;
  74.     
  75.     CloseTheFiles();
  76.     
  77.     return TRUE;
  78. }
  79.